/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Paul
 */
@Entity
@Table(name = "cursus")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cursus.findAll", query = "SELECT c FROM Cursus c"),
    @NamedQuery(name = "Cursus.findByIdCursus", query = "SELECT c FROM Cursus c WHERE c.idCursus = :idCursus"),
    @NamedQuery(name = "Cursus.findByNomCursus", query = "SELECT c FROM Cursus c WHERE c.nomCursus = :nomCursus")})
public class Cursus implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idCursus")
    private Integer idCursus;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "nomCursus")
    private String nomCursus;
    @JoinTable(name = "cursus_module_asso", joinColumns = {
        @JoinColumn(name = "idCursus", referencedColumnName = "idCursus")}, inverseJoinColumns = {
        @JoinColumn(name = "idModule", referencedColumnName = "idModule")})
    @ManyToMany
    private Collection<Module> moduleCollection;
    @JoinTable(name = "cursus_session_asso", joinColumns = {
        @JoinColumn(name = "idCursus", referencedColumnName = "idCursus")}, inverseJoinColumns = {
        @JoinColumn(name = "idSession", referencedColumnName = "idSession")})
    @ManyToMany
    private Collection<Session> sessionCollection;

    public Cursus() {
    }

    public Cursus(Integer idCursus) {
        this.idCursus = idCursus;
    }

    public Cursus(Integer idCursus, String nomCursus) {
        this.idCursus = idCursus;
        this.nomCursus = nomCursus;
    }

    public Integer getIdCursus() {
        return idCursus;
    }

    public void setIdCursus(Integer idCursus) {
        this.idCursus = idCursus;
    }

    public String getNomCursus() {
        return nomCursus;
    }

    public void setNomCursus(String nomCursus) {
        this.nomCursus = nomCursus;
    }

    @XmlTransient
    public Collection<Module> getModuleCollection() {
        return moduleCollection;
    }

    public void setModuleCollection(Collection<Module> moduleCollection) {
        this.moduleCollection = moduleCollection;
    }

    @XmlTransient
    public Collection<Session> getSessionCollection() {
        return sessionCollection;
    }

    public void setSessionCollection(Collection<Session> sessionCollection) {
        this.sessionCollection = sessionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCursus != null ? idCursus.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cursus)) {
            return false;
        }
        Cursus other = (Cursus) object;
        if ((this.idCursus == null && other.idCursus != null) || (this.idCursus != null && !this.idCursus.equals(other.idCursus))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Cursus[ idCursus=" + idCursus + " ]";
    }
    
}
